<template>
  <div>
    <el-button size="mini" type="text" @click="to">{{ state == 100 ? "修改" : "详情" }}</el-button>
    <eForm ref="form" :sup-this="supThis" :is-add="false" :is-view="isView" />
  </div>
</template>
<script>
import eForm from './form'
export default {
  components: { eForm },
  props: {
    data: {
      type: Object,
      required: true
    },
    supThis: {
      type: Object,
      required: true
    },
    isView: {
      type: Boolean,
      required: true
    }
  },
  data() {
    return {
      state: 100
    }
  },
  created() {
    this.state = this.data.state
  },
  methods: {
    to() {
      const _this = this.$refs.form
      this.data.arriveTime = this.data.arriveTime === null ? this.data.arriveTime : new Date(this.data.arriveTime)
      this.data.finishTime = this.data.finishTime === null ? this.data.finishTime : new Date(this.data.finishTime)
      this.data.inputTime = this.data.inputTime === null ? this.data.inputTime : new Date(this.data.inputTime)
      this.data.startTime = this.data.startTime === null ? this.data.startTime : new Date(this.data.startTime)
      _this.fileList = []
      _this.form = {
        customerName: this.data.customerName,
        id: this.data.id,
        taskTitle: this.data.taskTitle,
        taskContent: this.data.taskContent,
        taskAddr: this.data.taskAddr,
        attachments: this.data.attachments,
        arriveTime: this.data.arriveTime,
        finishTime: this.data.finishTime,
        notes: this.data.notes,
        linker: this.data.linker,
        cellphone: this.data.cellphone,
        inputOperator: this.data.inputOperator,
        inputTime: this.data.inputTime,
        startTime: this.data.startTime,
        state: this.data.state,
        country: this.data.country,
        province: this.data.province,
        city: this.data.city,
        county: this.data.county
      }
      this.data.attachments.split(',').forEach(function(data, index) {
        if (data !== null && data !== '') {
          _this.fileList.push({ id: data, name: data, url: '/api/picture/' + data })
        }
      })
      _this.dialog = true
    }
  }
}
</script>

<style scoped>
  div{
    display: inline-block;
    margin-right: 3px;
  }
</style>
